#!/bin/bash

CC='ccache gcc-10'
CLANG='ccache clang-10'

EXE_GCC=main-gcc
EXE_CLANG=main-clang

echo "====="
echo "Clang:"
echo "======"

${CLANG} -x c++ -std=gnu++20 \
      -D__MAIN__ -DNDEBUG \
      -O3 -funroll-loops -ftree-vectorize -flto \
      -Wall -Warray-bounds -Wempty-body -Wunused-const-variable -Wunused-parameter -Winit-self -Wwrite-strings -Wmissing-braces -Wsign-compare -Wcast-align -Wpointer-arith -Wchar-subscripts \
      -Itsl \
      app.cpp \
      -lstdc++ -lpthread -lm \
      -o ${EXE_CLANG} && ./${EXE_CLANG}

echo "===="
echo "GCC:"
echo "===="

${CC} -x c++ -std=gnu++20 \
      -D__MAIN__ -DNDEBUG \
      -O6 -funroll-loops -ftree-vectorize -floop-interchange -floop-block -flto -ftree-partial-pre -fno-diagnostics-show-caret \
      -Wall -Warray-bounds -Wempty-body -Wunused-but-set-variable -Wunused-but-set-parameter -Winit-self -Wwrite-strings -Wmissing-braces -Wsign-compare -Wcast-align -Wpointer-arith -Wchar-subscripts \
      -Itsl \
      app.cpp \
      -lstdc++ -lpthread -lm \
      -o ${EXE_GCC} && ./${EXE_GCC}
